package com.itlong.cloud.app.resource;

import com.itlong.cloud.POJO.PO.AppTempFaceShowPO;
import com.itlong.cloud.app.service.IAppShowService;
import com.itlong.cloud.user.app.IAppShowServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Map;

/**
 * <desc>
 *  演示版App暴露接口实现类
 * </desc>
 *
 * @createDate 2018/3/6
 */
@RestController
public class AppShowServiceResource implements IAppShowServiceClient {

    @Autowired
    private IAppShowService iAppShowService;

    /**
     * <desc>
     *      根据userId查询余额
     * <desc/>
     * @param  userId   带查询的userId
     * @return 余额
     * @author Biao.R
     * @createDate 2018/3/6
     */
    @PostMapping(path = "/show/getBalanceByUserId")
    @Override
    public BigDecimal getBalanceByUserId(@RequestParam("userId") String userId) {
        return iAppShowService.getBalanceByUserId(userId);
    }

    /**
     * <desc>
     *      人脸识别演示向账户充值或扣费
     * <desc/>
     * @param   faceShowPO  人脸识别PO
     * @return  人脸识别PO
     * @author Biao.R
     * @createDate 2018/3/6
     */
    @PostMapping(path = "/show/updateBalance")
    public Map<String, Object> updateBalance(@RequestBody AppTempFaceShowPO faceShowPO) {
        return iAppShowService.updateBalance(faceShowPO);
    }
}